package top.huxy.boot.controller.publicly;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.huxy.boot.annotation.Operation;
import top.huxy.boot.annotation.RequestCD;
import top.huxy.boot.model.dto.DTO_AddShareSite;
import top.huxy.boot.service.ShareSiteService;
import top.huxy.boot.service.ImageService;
import top.huxy.boot.util.obj.Result;

/**
 * @author HuXY
 * @Date 2021年12月31日16:17:56
 */
@RequestMapping("/shareSite")
@RestController
public class ShareSiteController {
    @Autowired
    private ShareSiteService shareSiteService;

    @Autowired
    ImageService imageService;

    @RequestCD
    @Operation("分享网址")
    @PostMapping("/addShareSite")
    public Result add(DTO_AddShareSite dtoAddShareSite) {
        if (imageService.checkYzm(dtoAddShareSite.getYzm())) {
            return Result.clientError("验证码错误");
        }
        this.shareSiteService.insert(dtoAddShareSite);
        return Result.success("添加成功");
    }
}
